--
-- Author: yao.chen
-- Date: 2018-09-21 
--
-- RewardMiraculousCard
-- 奇迹卡牌
--
local RewardMiraculousCard = class("RewardMiraculousCard", function(node) return node end)

local openTimeHints = "CardOpenTime"
local math_floor = math.floor
local math_mod = math.mod
local string_format = string.format

function RewardMiraculousCard:ctor()
	self._cardTips = self:findChild("Panel/tips_0")
	self._panelLock = self:findChild("Panel/Panel_lock")
end

function RewardMiraculousCard:refresh(data, timeStr)
	if data == 1 then
		self._cardTips:setVisible(false)
		self._panelLock:setVisible(false)
	else
		self._cardTips:setVisible(true)
		local lvIndex = math_floor(data / 2)
		local lvMod = math_mod(data, 2) + 1		
		local lvStr = openTimeHints .. tostring(lvIndex) 
			
		self._cardTips:setString(string_format(L(lvStr), timeStr[lvMod]))		
		self._panelLock:setVisible(true)
	end
end

function RewardMiraculousCard:setData(data, timeStr)
	self:refresh(data, timeStr)
end

return RewardMiraculousCard
